/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package phpgen;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

/**
 *
 * @author Alyson
 */
public class teste
{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws SQLException
    {
        Connection con = null;

        try
        {
            // Este é um dos meios para registrar um driver
            Class.forName("org.postgresql.Driver").getInterfaces();
        } catch (ClassNotFoundException ex)
        {
        }

        // Registrado o driver, vamos estabelecer uma conexão
        con = DriverManager.getConnection("jdbc:postgresql://172.18.4.24:5432/d_sca", "postgres", "secjus@2007");

        try
        {
            // Gets the database metadata
            DatabaseMetaData dbmd = con.getMetaData();

            // Specify the type of object; in this case we want tables
            String[] types =
            {
                "TABLE"
            };
            ResultSet resultSet = dbmd.getTables(null, null, "%", types);

            // Get the table names
            while (resultSet.next())
            {
                String tableName = resultSet.getString(3);
                String tableCatalog = resultSet.getString(1);
                String tableSchema = resultSet.getString(2);

                System.out.println(tableSchema + " : " + tableName+ "\n");
            }
        } catch (SQLException e)
        {
        }

    }

    public ArrayList listarTabelas()
    {
        ArrayList tabelas = new ArrayList();

        

        return tabelas;
    }

    public ArrayList listarEsquemas()
    {
        ArrayList tabelas = new ArrayList();



        return tabelas;
    }
}
